﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

public class ArrayHelper
{
    #region Double數組最大值
    /// <summary>
    /// Double數組最大值
    /// </summary>
    /// <param name="array"></param>
    /// <returns></returns>
    public static double DoubleMax(double[] array)
    {
        if (array == null)
            return 0;
        if (array.Length <= 0)
            return 0;
        double max = array[0];
        for (int i = 1; i < array.Length; i++)
        {
            if (max < array[i])
            {
                max = array[i];
            }
        }
        return max;
    }
    #endregion

    #region Double數組最小值
    /// <summary>
    /// Double數組最小值
    /// </summary>
    /// <param name="array"></param>
    /// <returns></returns>
    public static double DoubleMin(double[] array)
    {
        if (array == null)
            return 0;
        if (array.Length <= 0)
            return 0;
        double min = array[0];
        for (int i = 1; i < array.Length; i++)
        {
            if (min > array[i])
            {
                min = array[i];
            }
        }
        return min;
    }
    #endregion

    #region int數組最大值
    /// <summary>
    /// int數組最大值
    /// </summary>
    /// <param name="num"></param>
    /// <returns></returns>
    public static int IntMax(int[] num)
    {
        if (num == null)
            return 0;
        if (num.Length <= 0)
            return 0;
        int a = num[0];
        for (int i = 0; i < num.Length; i++)
        {
            if (a < num[i])
            {
                a = num[i];
            }
        }
        return a;
    }
    #endregion

    #region int數組最小值
    /// <summary>
    /// int數組最小值
    /// </summary>
    /// <param name="num"></param>
    /// <returns></returns>
    public static int IntMin(int[] num)
    {
        if (num == null)
            return 0;
        if (num.Length <= 0)
            return 0;
        int a = num[0];
        for (int i = 0; i < num.Length; i++)
        {
            if (a > num[i])
            {
                a = num[i];
            }
        }
        return a;
    }
    #endregion
}
